package com.talkweb.platform.commonapi.base;

import java.util.List;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.talkweb.platform.commonapi.base.response.Response;
import com.talkweb.platform.commonapi.log.SystemControllerLog;

/**
 * 通用增删改查微服务接口
 * 
 * @author lzy
 */
public interface ICRUDMicroApi<T>
{
    
    /**
     * 新增
     *
     * @param entity
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @SystemControllerLog(description="ICRUDMicroApi新增")
    public Response<T> add(@RequestBody T entity);
    
    
    /**
     * 根据批量添加对象
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/batchAdd", method = RequestMethod.POST)
    @SystemControllerLog(description="ICRUDMicroApi批量新增")
    public Response<T> batchAdd(@RequestBody List<T> entityList);
    
    /**
     * 根据ID删除
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    @SystemControllerLog(description="ICRUDMicroApi根据ID删除")
    public Response<T> delete(@PathVariable("id") String id);
    
    /**
     * 根据联合主键删除对象
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/deleteByEntity", method = RequestMethod.POST)
    @SystemControllerLog(description="ICRUDMicroApi删除")
    public Response<T> deleteByEntity(@RequestBody T entity);
    
    
    /**
     * 根据联合主键批量删除对象
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/batchDeleteByEntity", method = RequestMethod.POST)
    @SystemControllerLog(description="ICRUDMicroApi批量删除")
    public Response<T> batchDeleteByEntity(@RequestBody List<T> entityList);
    
    /**
     * 更新
     *
     * @param T
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @SystemControllerLog(description="ICRUDMicroApi更新")
    public Response<T> update(@RequestBody T entity);
    
    
    /**
     * 批量更新
     *
     * @param T
     * @return
     */
    @RequestMapping(value = "/batchUpdate", method = RequestMethod.POST)
    @SystemControllerLog(description="ICRUDMicroApi批量更新")
    public Response<T> batchUpdate(@RequestBody List<T> entityList);
    
}
